package com.gozap.struts.action;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.gozap.email.service.HelloWorldService;
import com.gozap.model.User;
import com.gozap.util.BizxingConstants;
import com.opensymphony.xwork2.ActionContext;

public class HelloWorldMyGirlAction extends BaseAction {

	private static final long serialVersionUID = 5340432951243841226L;

	private User user;
	private String other;

	private HelloWorldService helloWorldService;
	
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public HelloWorldService getHelloWorldService() {
		return helloWorldService;
	}

	public void setHelloWorldService(HelloWorldService helloWorldService) {
		this.helloWorldService = helloWorldService;
	}
	
	public String getOther() {
		return other;
	}

	public void setOther(String other) {
		this.other = other;
	}

	public String getUserInfoMyGirl(){
		
		Map<String, Object> session=ActionContext.getContext().getSession();
		HttpServletRequest request=ServletActionContext.getRequest();
		
		if(other==null){
			System.out.println("null");
		}else if("".equals(other)){
			System.out.println("kong str");
		}else{
			System.out.println(other);
		}
		String code=(String) session.get(BizxingConstants.AUTH_IMG);
//		System.out.println(code);
		request.setAttribute("msg", code);
		session.remove(BizxingConstants.AUTH_IMG);
		
		System.out.println(request.getParameter("JESSIONID"));
		
		List<User> arr=new ArrayList<User>();
		
		User user=new User();
		user.setInte(12);
		user.setPassword("password");
		arr.add(user);
		
		User user1=new User();
		user1.setInte(13);
		user1.setPassword("pass");
		arr.add(user1);
		
		request.setAttribute("arr", arr);
		
		return "success";
	}
	
	/**
	 * 
	 * @return
	 */
	public String gotInfo(){
		
		HttpServletRequest request=ServletActionContext.getRequest();
		
		System.out.println(request.getAttribute("arr"));
		
//		List<User> arrList=(List<User>) request.getAttribute("arr");
		
//		System.out.println(arrList.size());
		return "gotInfo";
	}


}
